/**
 * Created by cchen on 2015/5/19.
 */


var messageUtil = require('../../common/utils/messageUtil');
var toolUtil = require('../../common/utils/toolUtil');
var invoiceRetailerService = require('../../services/backoffice/backOffice-invoiceRetailer-service');

onError=function(msg,err, req,res){
    logger.error('Invoice Retailer controller '+msg+'  - - ' + err.message?err.message:'error');
    res.json(messageUtil.composeFailedMessage(req, err.message));
}

onSuccess=function(data,req,res)
{
    res.json(messageUtil.composeSucceededMessage(req, null, data));
}

onResponse=function(err,data,req,res){
    if(err){
        onError(err.message,err,req,res);
    }else {
        onSuccess(data, req, res);
    }
}

exports.getBalance=function(req,res){
    invoiceRetailerService.getBalance(req.cparams, function(err,result){
        onResponse(err,result,req,res)
    })

}

exports.invoiceRetails=function(req,res){
    invoiceRetailerService.invoiceRetails(req.body, function(err,result){
        onResponse(err,result,req,res)
    })
}